Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencc中文路径问题 #654

Closed
wants to merge 11 commits into from
Closed

opencc中文路径问题 #654

wants to merge 11 commits into from

Conversation

Techince
Copy link

修复Windows下用户词库所在路径包含中文的问题。

修复Windows下opencc中文路径问题
在64位项目中引用时,需要使会话ID统一大小,由于底层传上来的是指针,32位程序要使用UINT64来保存它,这里要将类型统一,否则模板就匹配不上。
修复opencc对中文路径的支持
修复Win平台用户目录中缺少「default.custom.yaml」、「weasel.custom.yaml」两个文件时,设定窗口无法打开
@Techince
Copy link
Author

Windows平台下首次安装时,用户目录里没有「default.custom.yaml」、「weasel.custom.yaml」两个文件,设定窗口无法打开。目前测试,Windows平台可正常运行修改过的代码。

@@ -36,7 +40,21 @@ class Opencc {
LOG(INFO) << "initializing opencc: " << config_path;
opencc::Config config;
try {
#ifdef WIN32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议把这段提炼成单个方法,方便其他地方引用

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者也可以使用 OpenCC 的方法来实现,这样就不用自己费劲写了:

https://github.com/BYVoid/OpenCC/blob/5750d92a92ac1f2d64c880c1f6f1a5e382d7d199/src/UTF8Util.hpp#L256-L289

Copy link
Author

@Techince Techince Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

似乎只有Windows平台使用多字节字符串路径,这个转换只有opencc会用到,别的地方用不到了。其它平台在这里传入的是utf8,Windows平台传入的却是多字节,而opencc要求必须传入utf8字符串。

@@ -43,7 +43,7 @@ bool CustomSettings::Load() {
fs::path custom_config_path =
fs::path(deployer_->user_data_dir) / custom_config_file(config_id_);
if (!custom_config_.LoadFromFile(custom_config_path.string())) {
return false;
return false;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前是改过的。但梁大说这两个文件在Weasel端创建,librime是几个平台共用的库,不应该创建平台相关的文件。所以就删除了。

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, 我的意思是行尾不应该多个空格, 让你困扰了。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在网页上改的,有时候空格没注意到。文件当时是本机编译的,环境变量不太一样,用github同步时会冲突,只网页上修改了相关的代码片断。

@eagleoflqj
Copy link
Member

Closing in favor of #689

@eagleoflqj eagleoflqj closed this Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants